package com.yeskery.nut.web.demo.controller;

import com.yeskery.nut.annotation.web.*;
import com.yeskery.nut.core.MultipartFile;
import com.yeskery.nut.web.demo.common.R;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 多参数测试
 * @author YESKERY
 * 2023/11/15
 */
@RestController
public class MultiParamController {

    @GetMapping("/multiParams")
    public R<?> multiParamsQuery(@RequestParam("age") List<String> ages) {
        return R.ok(ages);
    }

    @PostMapping("/multiParams")
    public R<?> multiParamsFile(@RequestParam("file") List<MultipartFile> files) {
        return R.ok(files.stream().map(MultipartFile::getFileName).collect(Collectors.toList()));
    }

    @PutMapping("/multiParams")
    public R<?> multiParamsForm(@RequestParam("age") List<String> ages) {
        return R.ok(ages);
    }
}
